import psutil
import platform
import subprocess

class Monitor:
    @staticmethod
    def get_cpu_usage():
        return psutil.cpu_percent(interval=1)

    @staticmethod
    def get_memory_usage():
        mem = psutil.virtual_memory()
        return {'total': mem.total, 'used': mem.used, 'percent': mem.percent}

    @staticmethod
    def get_disk_usage():
        disk = psutil.disk_usage('/')
        return {'total': disk.total, 'used': disk.used, 'percent': disk.percent}

    @staticmethod
    def ping(host):
        param = '-n' if platform.system().lower()=='windows' else '-c'
        command = ['ping', param, '4', host]
        try:
            output = subprocess.check_output(command, universal_newlines=True)
            return output
        except Exception as e:
            return str(e)